From e957a7cb4af70d66ce09acfc78a2835980cbb1a1 Mon Sep 17 00:00:00 2001 From: "kaf24@firebug.cl.cam.ac.uk" Date: Fri, 1 Sep 2006 00:20:42 +0100 Subject: [PATCH] Add xenbus_strstate() helper function for more readable debug output. From: Gerd Hoffmann Signed-off-by: Keir Fraser --- .../drivers/xen/xenbus/xenbus_client.c | 14 ++++++++++++++ .../drivers/xen/xenbus/xenbus_probe.c | 5 +++-- linux-2.6-xen-sparse/include/xen/xenbus.h | 2 ++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c index 97505ae459..e08e88818e 100644 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c @@ -41,6 +41,20 @@ extern char *kasprintf(const char *fmt, ...); #define DPRINTK(fmt, args...) \ pr_debug("xenbus_client (%s:%d) " fmt ".\n", __FUNCTION__, __LINE__, ##args) +char *xenbus_strstate(enum xenbus_state state) +{ + static char *name[] = { + [ XenbusStateUnknown ] = "Unknown", + [ XenbusStateInitialising ] = "Initialising", + [ XenbusStateInitWait ] = "InitWait", + [ XenbusStateInitialised ] = "Initialised", + [ XenbusStateConnected ] = "Connected", + [ XenbusStateClosing ] = "Closing", + [ XenbusStateClosed ] = "Closed", + }; + return (state < ARRAY_SIZE(name)) ? name[state] : "INVALID"; +} + int xenbus_watch_path(struct xenbus_device *dev, const char *path, struct xenbus_watch *watch, void (*callback)(struct xenbus_watch *, diff --git a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c index dc48ad0932..4f5be0fe2e 100644 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c @@ -316,8 +316,9 @@ static void otherend_changed(struct xenbus_watch *watch, state = xenbus_read_driver_state(dev->otherend); - DPRINTK("state is %d, %s, %s", - state, dev->otherend_watch.node, vec[XS_WATCH_PATH]); + DPRINTK("state is %d (%s), %s, %s", state, xenbus_strstate(state), + dev->otherend_watch.node, vec[XS_WATCH_PATH]); + if (drv->otherend_changed) drv->otherend_changed(dev, state); } diff --git a/linux-2.6-xen-sparse/include/xen/xenbus.h b/linux-2.6-xen-sparse/include/xen/xenbus.h index 909900f650..993f317b7c 100644 --- a/linux-2.6-xen-sparse/include/xen/xenbus.h +++ b/linux-2.6-xen-sparse/include/xen/xenbus.h @@ -297,4 +297,6 @@ void xenbus_dev_fatal(struct xenbus_device *dev, int err, const char *fmt, int __init xenbus_dev_init(void); +char *xenbus_strstate(enum xenbus_state state); + #endif /* _XEN_XENBUS_H */ -- 2.30.2